import React, { useState } from 'react';
import { message,Button } from 'antd';
import { useNavigate } from 'react-router-dom';
import './login.css'; // 导入 CSS 文件

const Logout = () => {
    const [token, setToken] = useState(() => localStorage.getItem('token'));
    const navigate = useNavigate();
    const logout = () => {
        localStorage.removeItem('token');
        setToken(null);
        message.info('已退出登录');
        navigate('/login', { replace: true });
    };

    return (
        <div className="logout-container">
            <Button danger onClick={logout} className="logout-button" block>
                退出登录
            </Button>
        </div>
    );
};

export default Logout;